package dialogos;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.FocusTraversalPolicy;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Hashtable;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;

import datos.Producto;

import accesoADatos.AccesoADatos;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ServicioColorDialog extends javax.swing.JOptionPane {
	
	private JLabel lCodigoBarras;
	private JLabel lCantidad;
	private JPanel jPanel;
	private JButton bCancelar;
	private JButton bAceptar;
	private JTextArea jTextArea1;
	private JSpinner sCantidad;
	private JFormattedTextField ftCodigo;
	private Hashtable hash = new Hashtable();

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				ServicioColorDialog inst = new ServicioColorDialog(frame);
			}
		});
	}
	
	public ServicioColorDialog(JFrame frame) {
		super();
		List productos = AccesoADatos.getInstance().getProductos();
		Producto p;
		for(int i=0; i<productos.size(); i++){
			p = (Producto)productos.get(i);
			this.hash.put(p.getCodigoBarra(), p);
		}
		initGUI();
		this.setVisible(true);
	}
	
	private void initGUI() {
		try {
			/*FlowLayout thisLayout = new FlowLayout();
			thisLayout.setHgap(10);
			thisLayout.setVgap(0);
			getContentPane().setLayout(thisLayout);*/
			{
				jPanel = new JPanel();
				//getContentPane().
				add(jPanel);
				FlowLayout jPanelLayout = new FlowLayout();
				jPanelLayout.setAlignment(FlowLayout.LEFT);
				jPanelLayout.setHgap(10);
				jPanelLayout.setVgap(10);
				jPanel.setLayout(jPanelLayout);
				jPanel.setPreferredSize(new java.awt.Dimension(394, 103));
				{
					jTextArea1 = new JTextArea();
					jPanel.add(jTextArea1);
					jTextArea1.setText("Ingrese el codigo de barras y la cantidad del producto utilizado");
					jTextArea1.setPreferredSize(new java.awt.Dimension(359, 20));
					jTextArea1.setOpaque(false);
					jTextArea1.setFont(new java.awt.Font("Tahoma",1,11));
					jTextArea1.setEditable(false);
				}
				{
					lCodigoBarras = new JLabel();
					jPanel.add(lCodigoBarras);
					lCodigoBarras.setText("Codigo de Barras");
					lCodigoBarras.setPreferredSize(new java.awt.Dimension(180, 20));
					lCodigoBarras.setHorizontalAlignment(SwingConstants.CENTER);
					lCodigoBarras.setBorder(BorderFactory.createTitledBorder(""));
				}
				{
					ftCodigo = new JFormattedTextField(new Integer(0));
					jPanel.add(ftCodigo);
					ftCodigo.setPreferredSize(new java.awt.Dimension(150, 20));
					ftCodigo.setNextFocusableComponent(this);
				}
				{
					lCantidad = new JLabel();
					jPanel.add(lCantidad);
					lCantidad.setText("Cantidad");
					lCantidad.setPreferredSize(new java.awt.Dimension(180, 20));
					lCantidad.setHorizontalAlignment(SwingConstants.CENTER);
					lCantidad.setBorder(BorderFactory.createTitledBorder(""));
				}
				{
					Double value = new Double(1);
					Double max = new Double(10);
					Double min = new Double(0);
					Double step = new Double(0.5);
					SpinnerNumberModel modelo = new SpinnerNumberModel(value, min, max, step); 
					sCantidad = new JSpinner(modelo);
					jPanel.add(sCantidad);
					sCantidad.setPreferredSize(new java.awt.Dimension(80, 20));
				}
			}
			{
				/*bAceptar = new JButton();
				getContentPane().add(bAceptar);
				bAceptar.setText("Aceptar");
				bAceptar.setPreferredSize(new java.awt.Dimension(100, 25));
				bAceptar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						if(hash.contains(ftCodigo.getText())){
							
						}
						else{
							
						}
					}
				});*/
			}
			{
				/*bCancelar = new JButton();
				getContentPane().add(bCancelar);
				bCancelar.setText("Cancelar");
				bCancelar.setPreferredSize(new java.awt.Dimension(100, 25));
				bCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						ServicioColorDialog.this.dispose();
					}
				});*/
			}
			//this.pack();
			this.setSize(409, 175);
			//this.setLocationRelativeTo(null);
			this.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
